layui.define(['layer', 'jquery'], function(exports){
    var $ = layui.jquery
        ,layer = layui.layer;
    var obj = {
        post: function(url, data, func){
            var load = layer.load();

            if(func == undefined){
                var func = function(json){
                    layer.close(load);
                    if(json.code==0){
                        layer.msg(json.msg, {icon: 1, time:1000})
                    }else{
                        layer.msg(json.msg, {icon: 2, time:1000});
                    }
                };
            }
            $.post(url,data, func, 'JSON').error(function(){
                layer.close(load);
                layer.msg('连接超时，请联系后台管理员', {icon: 0, time:3000});
            });
        }
    };

    //输出test接口
    exports('common', obj);
});